<template>
  <div class="home">
    <HomeHeader></HomeHeader>
    <Swiper :list="swiperList"></Swiper>
    <Icons :list="iconList"></Icons>
    <Recommend :list="recommendList"></Recommend>
    <Weekend :list="weekendList"></Weekend>
  </div>
</template>

<script>
// @ is an alias to /src
// import HelloWorld from '@/components/HelloWorld.vue'
import HomeHeader from '@/components/Header.vue'
import Swiper from '@/components/Swiper.vue'
import Icons from '@/components/Icons.vue'
import Recommend from '@/components/Recommend.vue'
import Weekend from '@/components/Weekend.vue'

export default {
  name: 'Home',
  components: {
    // HelloWorld
    HomeHeader,
    Swiper,
    Icons,
    Recommend,
    Weekend
  },
  data(){
    return {
      city:"",
      swiperList:[],
      iconList:[],
      recommendList:[],
      weekendList:[],
    }
  },
  methods:{
    getHomeInfo(){
      // this.$http.get("http://localhost:8080/mock/index.json").then(this.getHomeInfoSucc)
      this.$http.get("/api/index.json").then(this.getHomeInfoSucc)
    },
    //获取数据的方法
    getHomeInfoSucc(res){
      console.log(res.data);
      res = res.data;
      if (res.ret && res.data) {
        const data = res.data;
        this.city = data.city;
        this.swiperList = data.swiperList;
        this.iconList = data.iconList;
        this.recommendList = data.recommendList;
        this.weekendList = data.weekendList;
      }
    }
  },
  mounted(){
    this.getHomeInfo();
  }

}
</script>
